//
//  HamatonLoginManager.swift
//  grid-ios-app
//
//  Created by wondertek on 2024/3/21.
//

import UIKit

class HamatonLoginManager  {
    /// 单例
    static let shared = HamatonLoginManager()
    private var loginState: Bool
    private init() {
        //  token
        if (UserDefaults.standard.string(forKey: "HamatonLoginToken") != nil) {
            loginState = true
        }else {
            loginState = false
        }
    }
    
    public func updateToken(token: String) {
        UserDefaults.standard.set(token, forKey: "HamatonLoginToken")
        UserDefaults.standard.synchronize()
        loginState = true
    }
    
    public func removeToken() {
        UserDefaults.standard.removeObject(forKey: "HamatonLoginToken")
        UserDefaults.standard.synchronize()
        loginState = false
    }
    
    public func isLogin() -> Bool {
        return loginState
    }
}
